home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / lib / udev / dsl-modem.agent < prev    next >
Encoding:
Text File  |  2010-12-12  |  2.2 KB  |  103 lines

  1. #!/bin/sh -e 
  2. #
  3. # Copyright 2008 Marco d'Itri <md@Linux.IT>
  4. #
  5. # This script automatically starts networking when a DSL modem is connected
  6. # and its ATM interface is ready.
  7. #
  8. #
  9. # For PPPoE you can set PROTOCOL=2684bridged and then add something like
  10. # this to /etc/network/interfaces:
  11. #
  12. # allow-hotplug nas0
  13. # iface nas0 inet manual
  14. #        pre-up          ip link set up $IFACE
  15. #        up              pppd persist call dsl-provider
  16. #
  17. #
  18. # Support for CLIP (Classical IP over ATM, RFC 1577) may be incomplete.
  19. #
  20.  
  21. # defaults
  22. [ "$IP_INTERFACE" ] || IP_INTERFACE='nas0'
  23. [ "$VP" ] || VP='8'
  24. [ "$VC" ] || VC='35'
  25.  
  26. if [ -e /etc/default/dsl-modem.agent ]; then
  27.   . /etc/default/dsl-modem.agent
  28. fi
  29.  
  30. # just exit unless a protocol is configured
  31. [ "$PROTOCOL" ] || exit 0
  32.  
  33. ##############################################################################
  34. wait_and_run_pppd() {
  35.   # this guarantees that everything pppd needs to work is ready
  36.   wait_for_file /dev/log
  37.  
  38.   exec pppd persist call ${PPP_PEER:-dsl-provider}
  39. }
  40.  
  41. wait_and_run_br2684ctl() {
  42.   wait_for_file /dev/log
  43.  
  44.   exec br2684ctl $BR2684_ARGS -b -c ${IP_INTERFACE#nas} \
  45.     -a ${ATM_INTERFACE}.${VP}.${VC}
  46. }
  47.  
  48. wait_and_run_atmarp() {
  49.   wait_for_file /var/run/atmarpd.table
  50.  
  51.   # create the IP interface
  52.   atmarp -c ${IP_INTERFACE:-atm0}
  53.   # setup the VC
  54. #  atmarp -s 192.0.2.254 ${ATM_INTERFACE}.${VP}.${VC}
  55.   exec ifup ${IP_INTERFACE:-atm0} # XXX
  56. }
  57.  
  58. ##############################################################################
  59. ATM_DRIVER=${NAME%%[0-9]*}
  60. ATM_INTERFACE=${NAME##$ATM_DRIVER}
  61.  
  62. # is this a DSL modem?
  63. case "$ATM_DRIVER" in
  64. cxacru|speedtch|ueagle-atm|xusbatm|UNICORN) ;;
  65. *) exit 0 ;;
  66. esac
  67.  
  68. cd /lib/udev/
  69. . ./hotplug.functions
  70.  
  71. ##############################################################################
  72. case "$ACTION" in
  73. add)
  74.   case "$PROTOCOL" in
  75.   pppoa)    wait_and_run_pppd & ;;
  76.   2684bridged)    wait_and_run_br2684ctl & ;;
  77.   clip)        wait_and_run_atmarp & ;;
  78.   esac
  79.   ;;
  80.  
  81. remove)
  82.   case "$PROTOCOL" in
  83.   pppoa)
  84.     # pppd will terminate automatically
  85.     ;;
  86.   2684bridged)
  87.     PIDFILE="/var/run/br2684ctl-$IP_INTERFACE.pid"
  88.     if [ -e $PIDFILE ]; then
  89.       kill $(cat $PIDFILE)
  90.       rm -f $PIDFILE
  91.     fi
  92.     ;;
  93.   clip)
  94.     ifdown ${IP_INTERFACE:-atm0} # XXX
  95. #    atmarp -d 192.0.2.254
  96.     ;;
  97.   esac
  98.   ;;
  99. esac
  100.  
  101. exit 0
  102.  
  103.